//
//  RHMessageCell.m
//  RuiHeAppApp
//
//  Created by Jun on 2023/7/21.
//

#import "RHMessageCell.h"

@interface RHMessageCell()

@property (nonatomic ,strong) UIImageView *iconV;

@property (nonatomic ,strong) QMUILabel *titleLab;

@end

@implementation RHMessageCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        [self setupUI];
    }
    return self;
}

- (void)setupUI{
    
    [self setBackgroundColor:UIColor.clearColor];
    [self.contentView setBackgroundColor:UIColor.clearColor];

    UIView *bgView = [[UIView alloc] init];
    [bgView setBackgroundColor:UIColor.whiteColor];
    [self.contentView addSubview:bgView];
    
    _iconV = [[UIImageView alloc] init];
    [bgView addSubview:_iconV];
    
    _titleLab = [[QMUILabel alloc] init];
    [_titleLab setTextAlignment:NSTextAlignmentLeft];
    [_titleLab setFont:[UIFont systemFontOfSize:15]];
    [_titleLab setTextColor:kCOLOR_HEX(@"3F4443")];
    [bgView addSubview:_titleLab];
    
    UIImageView *arrowV = [[UIImageView alloc] init];
    [arrowV setImage:[UIImage imageNamed:@"cell_arrow"]];
    [bgView addSubview:arrowV];
    
    UIView *lineV = [[UIView alloc] init];
    [lineV setBackgroundColor:CFCellLineColor];
    [bgView addSubview:lineV];
    
    kWeakSelf;
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.insets(UIEdgeInsetsMake(0, 15, 0, 15));
    }];
    
    [_iconV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(24, 24));
        make.left.mas_offset(15);
        make.centerY.mas_offset(0);
    }];
    
    [_titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.iconV.mas_right).offset(10);
        make.height.mas_equalTo(30);
        make.right.mas_offset(-100);
        make.top.mas_equalTo(10);
        make.bottom.mas_offset(-10);
    }];
    
    [arrowV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(20, 20));
        make.right.mas_offset(-15);
        make.centerY.mas_offset(0);
    }];
    
    [lineV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(1);
        make.left.mas_offset(15);
        make.right.mas_offset(-15);
        make.bottom.mas_offset(0);
    }];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setTitleStr:(NSString *)titleStr{
    _titleStr = titleStr;
    [self.titleLab setText:_titleStr];
}

- (void)setIconStr:(NSString *)iconStr{
    _iconStr = iconStr;
    [self.iconV setImage:[UIImage imageNamed:_iconStr]];
}

@end
